package com.zhang.apipassenger.constraints;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;
import java.util.List;

/**
 * 类功能描述
 *
 * @author Kye
 * @date 2025-09-22
 */
public class VehicleTypeCheckValidator implements ConstraintValidator<VehicleTypeCheck, String> {
	private List<String> vehicleTypeCheckValue = null;

	@Override
	public void initialize(VehicleTypeCheck constraintAnnotation) {
		vehicleTypeCheckValue = Arrays.asList(constraintAnnotation.vehicleType());
		ConstraintValidator.super.initialize(constraintAnnotation);
	}

	@Override
	public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
		if (vehicleTypeCheckValue.contains(s)) {
			return true;
		}
		return false;
	}
}
